//
//  CentRedBagViewController.m
//  智积分
//
//  Created by Cynic on 2018/7/18.
//  Copyright © 2018年 Cynic. All rights reserved.
//

#import "CentRedBagViewController.h"
#import <ShareSDK/ShareSDK.h>
#import <ShareSDKUI/ShareSDK+SSUI.h>
#import "CentRedBagTableViewCell.h"
#import "CentRedBagFieldTableViewCell.h"
#import "RedBagSendBtnCell.h"
#import "CentRedBagNONoticeFieldTableViewCell.h"
#import "RedRecordListViewController.h"
static NSString *CentRedBagTableViewCellIdentifier = @"CentRedBagTableViewCellIdentifier";

static NSString *CentRedBagFieldTableViewCellIdentifier = @"CentRedBagFieldTableViewCellIdentifier";

static NSString *RedBagSendBtnCellIdentifier = @"RedBagSendBtnCellIdentifier";

static NSString *CentRedBagNONoticeFieldTableViewCellIdentifier = @"CentRedBagNONoticeFieldTableViewCellIdentifier";


@interface CentRedBagViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic ,retain)UITableView *MainView;
@property (nonatomic ,retain)NSMutableArray *baseData;
@property (nonatomic ,retain)NSMutableArray *resultData;
@property (nonatomic ,retain)UIView *centPartView;
@property (nonatomic ,retain)UILabel *deslabel;
@property (nonatomic ,retain)UILabel *centsed;//累计发放积分
@property (nonatomic ,retain)UILabel *rednumed;//总计红包数
@property (nonatomic ,retain)UILabel *rednumget;//共领红包
@property (nonatomic ,retain)NSMutableDictionary *centsData;
@property (nonatomic ,retain)UIButton *shareView;
@property (nonatomic ,retain)UILabel *topdes;
@property (nonatomic ,retain)UILabel *bottomdes;
@property (nonatomic ,retain)UIButton *header;
@property (nonatomic ,assign)NSInteger RedType;
@property (nonatomic ,copy)NSString *redid;
@end

@implementation CentRedBagViewController
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    _baseData = [@[@[@"总积分",@"输入积分数据"],@[@"总个数",@"输入红包个数"],@[@"留言",@"小小心意,请您笑纳"],@[@"留言",@"小小心意,请您笑纳"]] mutableCopy];
    _centsData = [@{
                    @"total_count" : @"0",
                    @"total_integral" : @"0",
                    @"total_record" : @"0"
                    } mutableCopy];
    _resultData = [@[@"",@"",@""] mutableCopy];
    self.view.backgroundColor = bggrayColor;
    [self viewLoad];
    [self totalCentsLoad];
}

-(void)totalCentsLoad{
    /**/
    NetWorkModel *netmodel = [[NetWorkModel alloc] init];
    [netmodel TotallRedInfoByID:cxsingler.loginrequest[@"admin"][@"shop_id"]];
    WEAKSELF;
    netmodel.sendMessage = ^(NSString *result) {
        if ([result isEqual:@"success"]) {
            weakSelf.centsData = [cxsingler.DicData mutableCopy];
            [weakSelf resetCents];
        }
        else{
            [SVProgressHUD showErrorWithStatus:result];
        }
    };
}


/**
 更新金额模块数据显示
 */
-(void)resetCents{
    _centsed.text = [NSString stringWithFormat:@"%@",_centsData[@"total_integral"]];
    _rednumed.text = [NSString stringWithFormat:@"共发%@红包",_centsData[@"total_count"]];
    _rednumget.text = [NSString stringWithFormat:@"共领%@红包",_centsData[@"total_record"]];
    
}

-(void)viewLoad{
    _RedType = 0;
    [self setNavigationViewWithTitle:@"红包积分" WithCanPop:YES WithPopData:@"return" WithPopisString:NO WithHasRightOperation:YES WithrightOperationData:@"icon_details" WithRightisString:NO WithNavigationColor:BaseColor withBgView:self.view];//icon_details
    CAGradientLayer *layer = [CAGradientLayer layer];
    layer.frame = self.navigationView.bounds;
    layer.colors = @[(id)[CXSinglerModel colorWithHex:@"#FF7F5A" alpha:1].CGColor,(id)[CXSinglerModel colorWithHex:@"#FE4438" alpha:1].CGColor];
    layer.startPoint = CGPointMake(0, 0);
    layer.endPoint = CGPointMake(1, 0);
    [self.navigationView.layer addSublayer:layer];
    [self.navigationView bringSubviewToFront:self.centerTitle];
    [self.navigationView bringSubviewToFront:self.popButton];
    [self.navigationView bringSubviewToFront:self.rightOperationButton];
    [self centPartViewLoad];
    [self LoadMainView];
    
}


-(void)centPartViewLoad{
    if (!_centPartView) {
        _centPartView = [[UIView alloc] initWithFrame:CGRectZero];
        _centPartView.backgroundColor = [UIColor whiteColor];
        _centPartView.layer.borderColor = [UIColor lightGrayColor].CGColor;
        _centPartView.layer.cornerRadius = 5;
        [self.view addSubview:_centPartView];
        
        UIImageView *bgimageView =[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, cx_wid, 150)];
        bgimageView.image = [UIImage imageNamed:@"bg_red_changecolor"];
        [_centPartView addSubview:bgimageView];
        
        
        [_centPartView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(cxsingler.topdis + 44);
            make.left.right.mas_equalTo(0);
            make.height.mas_equalTo(150);
            
        }];
        
        _deslabel = [[UILabel alloc] initWithFrame:CGRectZero];
        _deslabel.textColor = [UIColor whiteColor];
        _deslabel.textAlignment = NSTextAlignmentCenter;
        _deslabel.font = [UIFont systemFontOfSize:18];
        [_centPartView addSubview:_deslabel];
        [_deslabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_equalTo(0);
            make.top.mas_equalTo(19);
        }];
        
        _centsed = [[UILabel alloc] initWithFrame:CGRectZero];
        _centsed.font = [UIFont systemFontOfSize:36];
        _centsed.textColor = [UIColor whiteColor];
        [_centPartView addSubview:_centsed];
        [_centsed mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_equalTo(0);
            make.top.mas_equalTo(51);
        }];
        
        for (NSInteger index = 0; index < 2; index ++) {
            UILabel *partlabel = [[UILabel alloc] initWithFrame:CGRectZero];
            partlabel.font = [UIFont systemFontOfSize:18];
            partlabel.textColor = [UIColor whiteColor];
            partlabel.numberOfLines = 0;
            [_centPartView addSubview:partlabel];
            [partlabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.bottom.mas_equalTo(-16);
                if (index == 0) {
                    make.left.mas_equalTo(30);
                }
                else if (index == 1){
                    make.right.mas_equalTo(-30);
                }
            }];
            if (index == 0) {
                partlabel.textAlignment = NSTextAlignmentLeft;
                _rednumed = partlabel;
            }
            else if (index == 1){
                partlabel.textAlignment = NSTextAlignmentRight;
                _rednumget = partlabel;
            }
            [_centPartView addSubview:partlabel];
        }
        
    }
    _deslabel.text = @"累计发放积分";
    [self resetCents];
}

-(void)LoadMainView{
    if (!_MainView) {
        _MainView = [[UITableView alloc] initWithFrame:CGRectZero];
        _MainView.delegate = self;
        _MainView.dataSource = self;
        _MainView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _MainView.estimatedRowHeight = 44;
        _MainView.rowHeight = UITableViewAutomaticDimension;
        _MainView.backgroundColor = bggrayColor;
        [_MainView registerClass:[CentRedBagTableViewCell class] forCellReuseIdentifier:CentRedBagTableViewCellIdentifier];
        [_MainView registerClass:[CentRedBagFieldTableViewCell class] forCellReuseIdentifier:CentRedBagFieldTableViewCellIdentifier];
        [_MainView registerClass:[CentRedBagNONoticeFieldTableViewCell class] forCellReuseIdentifier:CentRedBagNONoticeFieldTableViewCellIdentifier];
        [_MainView registerClass:[RedBagSendBtnCell class] forCellReuseIdentifier:RedBagSendBtnCellIdentifier];
        [self.view addSubview:_MainView];
        WEAKSELF;
        [self.MainView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.mas_equalTo(0);
            make.top.mas_equalTo(weakSelf.centPartView.mas_bottom).mas_offset(20);
            make.bottom.mas_equalTo(-cxsingler.bottomdis);
        }];
    }
}

#pragma mark--uitableview代理satrt
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return _baseData.count;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSInteger sec = indexPath.section;
    NSInteger row = indexPath.row;
     WEAKSELF;
    if (sec == 2) {
        CentRedBagTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CentRedBagTableViewCellIdentifier];
        cell.backgroundColor = [UIColor clearColor];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.title.text = _baseData[sec][0];
        //        cell.notice.textColor
        cell.notice.text = @"留言最多25字";
       
        __weak typeof(cell) weakCell = cell;
        [cell.infoView cx_eventsChangeByHandler:^{
            NSLog(@"new infoview text = %@",weakCell.infoView.text);
            [weakSelf.resultData replaceObjectAtIndex:2 withObject:weakCell.infoView.text];
            [UIView performWithoutAnimation:^{
                [weakSelf.MainView beginUpdates];
                [weakSelf.MainView endUpdates];
            }];
        }];
        
        NSLog(@"info is %@",cell.infoView);
        cell.infoView.PlaceHolder.text = _baseData[sec][1];
        cell.infoView.max = 25;
        cell.infoView.text = _resultData[sec];
        cell.notice.text = @"留言最多25字";
        return cell;
    }
    else if (sec == 3){
        RedBagSendBtnCell *cell = [tableView dequeueReusableCellWithIdentifier:RedBagSendBtnCellIdentifier];
        cell.notice.text = [NSString stringWithFormat:@"总积分数额最高为%@",_centsData[@"total_integral"]];
        cell.backgroundColor = [UIColor clearColor];
        [cell.Sure cx_eventsBlockHandler:^{
            
            [weakSelf SendRed];
        } forControlEvents:UIControlEventTouchUpInside];
        return cell;
    }
    else if (sec == 1){
        CentRedBagNONoticeFieldTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CentRedBagNONoticeFieldTableViewCellIdentifier];
        cell.backgroundColor = [UIColor clearColor];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.title.text = _baseData[sec][0];
        cell.field.placeholder = _baseData[sec][1];
        cell.field.text = _resultData[sec];
        __weak typeof(cell) weakCell = cell;
        cell.field.keyboardType = UIKeyboardTypeNumberPad;
        [cell.field cx_eventsChangeByHandler:^{
            [weakSelf.resultData replaceObjectAtIndex:sec withObject:weakCell.field.text];
        }];
        return cell;
    }
    else{
        CentRedBagFieldTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CentRedBagFieldTableViewCellIdentifier];
        cell.field.keyboardType = UIKeyboardTypeDecimalPad;
        cell.backgroundColor = [UIColor clearColor];
        cell.logo.hidden = YES;
        if (sec == 0) {
            NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"当前为普通红包，改为随机红包"];
            [str addAttribute:NSForegroundColorAttributeName value:[UIColor ColorWithHex:@"9B9B9B" withAlpha:1] range:NSMakeRange(0,str.length)];
            [str addAttribute:NSForegroundColorAttributeName value:BaseColor range:NSMakeRange(str.length - 4,4)];
            //            cell.notice.attributedText = str;
            [cell.notice setAttributedTitle:str forState:UIControlStateNormal];
            __weak typeof(cell) weakCell = cell;
            [cell.field cx_eventsChangeByHandler:^{
                NSLog(@"new = %@",weakCell.field.text);
            }];
            NSMutableAttributedString *anotherstr = [[NSMutableAttributedString alloc] initWithString:@"当前为随机红包，改为普通红包"];
            [anotherstr addAttribute:NSForegroundColorAttributeName value:[UIColor ColorWithHex:@"9B9B9B" withAlpha:1] range:NSMakeRange(0,str.length)];
            [anotherstr addAttribute:NSForegroundColorAttributeName value:BaseColor range:NSMakeRange(str.length - 4,4)];
            [cell.notice setAttributedTitle:anotherstr forState:UIControlStateSelected];
            cell.notice.selected = _RedType;
            cell.title.frame = CGRectMake(45, 0, 70, 55);
            cell.logo.hidden = NO;
            if (_RedType == 0) {
                cell.title.text = @"单个积分";
            }
            else{
                cell.title.text = @"总积分";
            }
            //            __weak typeof(cell) weakCell = cell;
            WEAKSELF;
            [cell.notice cx_eventsBlockHandler:^{
                weakCell.notice.selected = !weakCell.notice.selected;
                weakSelf.RedType = 1 - weakSelf.RedType;
                dispatch_async(dispatch_get_main_queue(), ^{
                    if (weakSelf.RedType == 0) {
                        weakCell.title.text = @"单个积分";
                    }
                    else{
                        weakCell.title.text = @"总积分";
                    }
                });
                [weakSelf.MainView reloadData];
            } forControlEvents:UIControlEventTouchUpInside];
        }
        else{
            cell.title.frame = CGRectMake(15, 0, 70, 55);
            NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@""];
            [cell.notice setAttributedTitle:str forState:UIControlStateNormal];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
//        cell.title.text = _baseData[sec][0];
        cell.field.placeholder = _baseData[sec][1];
        cell.field.text = _resultData[sec];
        __weak typeof(cell) weakCell = cell;
        [cell.field cx_eventsChangeByHandler:^{
            [weakSelf.resultData replaceObjectAtIndex:sec withObject:weakCell.field.text];
        }];
        return cell;
    }
}


#pragma mark--uitableview代理end


#pragma mark--发送红包
-(void)SendRed{
    
    NSString *err = @"";
    if (![Utils isNumber:self.resultData[0]] || [self.resultData[0] isEqual:@"0"]) {
        err = @"请使用有效积分数字";
    }
    else if (![Utils isNumber:self.resultData[1]] || [self.resultData[1] isEqual:@"0"]){
        err = @"请使用有效个数";
    }
    else if ([self.resultData[0] floatValue] / [self.resultData[1] floatValue] < 1 && _RedType == 1){
        err = @"不符合最低每人1积分标准";
    }
    if (err.length > 0) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [SVProgressHUD showErrorWithStatus:err];
        });
        return;
    }
    
    [self.view endEditing:YES];
    [SVProgressHUD showWithStatus:@"生成红包中"];
    NetWorkModel *netmodel = [[NetWorkModel alloc] init];
    [netmodel SendOutRedBagsWithType:_RedType withPrice:_resultData[0] withCount:_resultData[1] withMessage:_resultData[2] withShopID:cxsingler.loginrequest[@"admin"][@"shop_id"]];
    WEAKSELF;
    netmodel.sendMessage = ^(NSString *result) {
        [SVProgressHUD dismiss];
        if ([result isEqual:@"success"]) {
            
            weakSelf.redid = cxsingler.StrData;
            dispatch_async(dispatch_get_main_queue(), ^{
                [SVProgressHUD showSuccessWithStatus:@"红包生成成功"];
                [weakSelf totalCentsLoad];
                if (!weakSelf.shareView) {
                    [weakSelf.view addSubview:weakSelf.shareView];
                }
                else{
                    weakSelf.shareView.hidden = NO;
                }
                [weakSelf.view bringSubviewToFront:weakSelf.shareView];
                [weakSelf setTopLabel];
                [weakSelf share];
            });
        }
        else{
            dispatch_async(dispatch_get_main_queue(), ^{
                [SVProgressHUD showErrorWithStatus:result];
            });
        }
    };
    
   
}

-(UIButton *)shareView{
    if (!_shareView) {
        _shareView = [[UIButton alloc] initWithFrame:CGRectMake(0, cxsingler.topdis, cx_wid, cx_hit - cxsingler.topdis - cxsingler.bottomdis)];
        _shareView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3];
        WEAKSELF;
        [_shareView cx_eventsBlockHandler:^{
            [weakSelf cancelShare];
        } forControlEvents:UIControlEventTouchUpInside];
        //分享icon背景
        UIView *shareIconBG = [[UIView alloc] initWithFrame:CGRectZero];
        shareIconBG.backgroundColor = [UIColor ColorWithHex:@"ECECEC" withAlpha:1];
        [_shareView addSubview:shareIconBG];
        [shareIconBG mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.mas_equalTo(0);
            make.bottom.mas_equalTo(-50);
            make.height.mas_equalTo(122);
        }];
        //微信icon
        UIButton *wxicon = [[UIButton alloc] initWithFrame:CGRectZero];
        wxicon.layer.cornerRadius = 5;
        wxicon.backgroundColor = [UIColor whiteColor];
        [wxicon setImage:[UIImage imageNamed:@"bitmap"] forState:UIControlStateNormal];
        [shareIconBG addSubview:wxicon];
        [wxicon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(24);
            make.top.mas_equalTo(20);
            make.size.mas_equalTo(CGSizeMake(61, 61));
        }];
        //微信名称
        UILabel *name = [[UILabel alloc] initWithFrame:CGRectZero];
        name.textColor = [UIColor ColorWithHex:@"666666" withAlpha:1];
        name.font = [UIFont systemFontOfSize:12];
        name.text = @"微信好友";
        name.textAlignment = NSTextAlignmentCenter;
        [shareIconBG addSubview:name];
        [name mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(24);
            make.width.mas_equalTo(61);
            make.top.mas_equalTo(87);
            make.height.mas_equalTo(17);
        }];
        //取消分享
        UIButton *shareCancel = [[UIButton alloc] initWithFrame:CGRectZero];
        shareCancel.backgroundColor = [UIColor whiteColor];
        [shareCancel setTitle:@"取消分享" forState:UIControlStateNormal];
        [shareCancel cx_eventsBlockHandler:^{
            [weakSelf cancelShare];
        } forControlEvents:UIControlEventTouchUpInside];
        [shareCancel setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        shareCancel.titleLabel.font = [UIFont systemFontOfSize:20];
        [_shareView addSubview:shareCancel];
        [shareCancel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.mas_equalTo(0);
            make.height.mas_equalTo(50);
        }];
        
        //
        UIView *centerView = [[UIView alloc] initWithFrame:CGRectZero];
        [_shareView addSubview:centerView];
        [centerView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_equalTo(0);
            make.size.mas_equalTo(CGSizeMake(260, 213));
            make.centerY.mas_equalTo(- 100);
        }];
        
        UIImageView *bg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 260, 213)];
        bg.image = [UIImage imageNamed:@"红包背景"];
        [centerView addSubview:bg];
        
        for (NSInteger index = 0; index < 2; index ++) {
            UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
            label.textAlignment = NSTextAlignmentCenter;
            [centerView addSubview:label];
            [label mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(10);
                make.right.mas_equalTo(-10);
                make.top.mas_equalTo(118 + 30 * index);
            }];
            if (index == 0) {
                _topdes = label;
                label.font = [UIFont systemFontOfSize:15];
            }
            else{
                _bottomdes = label;
                label.font = [UIFont systemFontOfSize:14];
                _bottomdes.text = @"小小心意，请您笑纳";
            }
            label.textColor = [UIColor blackColor];
        }
        
        UILabel *bottomlabel = [[UILabel alloc] initWithFrame:CGRectZero];
        bottomlabel.text = @"积分红包";
        bottomlabel.font = [UIFont systemFontOfSize:12];
        bottomlabel.textAlignment = NSTextAlignmentRight;
        bottomlabel.textColor = [UIColor ColorWithHex:@"4A4A4A" withAlpha:1];
        [centerView addSubview:bottomlabel];
        [bottomlabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.mas_equalTo(-10);
//            make.bottom.mas_equalTo(-12);
            make.height.mas_equalTo(12);
            make.right.mas_equalTo(-10);
        }];
        
        _header = [[UIButton alloc] initWithFrame:CGRectZero];
        _header.layer.cornerRadius = 34;
        _header.clipsToBounds = YES;
        _header.backgroundColor = bggrayColor;
        
        
        NSString *headerUrl = [NSString stringWithFormat:@"%@",cxsingler.loginrequest[@"logo"]];
        if ([headerUrl containsString:@"gif"]) {
            [_header setImage:[UIImage sd_animatedGIFWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:headerUrl]]] forState:UIControlStateNormal];
        }
        else{
            [_header sd_setBackgroundImageWithURL:[NSURL URLWithString:headerUrl] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"logo1"]];
        }
        
        [centerView addSubview:_header];
        [_header mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(68, 68));
            make.top.mas_equalTo(5);
            make.centerX.mas_equalTo(0);
        }];
    }
    return _shareView;
}



/**
 这一坨好像没用，具体记不清了
 */
-(void)setTopLabel{
    NSString *topstr = [NSString stringWithFormat:@"[%@]发红包啦~",cxsingler.loginrequest[@"admin"][@"name"]];
    NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:topstr];
    [str addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(0, topstr.length)];
    [str addAttribute:NSForegroundColorAttributeName value:[CXSinglerModel colorWithHex:@"f3a536" alpha:1] range:NSMakeRange(1, [cxsingler.loginrequest[@"admin"][@"name"] length])];
    _topdes.attributedText = str;
}

-(void)cancelShare{
    _shareView.hidden = YES;
}


/**
 sharesdk调用微信分享
 */
-(void)share{
    NSMutableDictionary *shareParams = [NSMutableDictionary dictionary];
    NSString *AccountID = cxsingler.loginrequest[@"admin"][@"shop_id"];
    NSString *urlstr = [NSString stringWithFormat:@"%@/shareRedPacket?shop_id=%@&red_packet_id=%@",redShareHeader,AccountID,_redid];
    UIImage *image = [UIImage imageNamed:@"logo1"];
    [shareParams SSDKSetupShareParamsByText:_resultData[2] images:image url:[NSURL URLWithString:urlstr] title:@"积分红包" type:SSDKContentTypeWebPage];
    
    [ShareSDK showShareActionSheet:nil items:nil shareParams:shareParams onShareStateChanged:^(SSDKResponseState state, SSDKPlatformType platformType, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error, BOOL end) {
        switch (state) {
                //这里的分享成功不具备参考价值
//
//                                      case SSDKResponseStateSuccess:
//
//                                      {
//
//                                              UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"分享成功"
//
//                                                                                                                                                      message:nil
//
//                                                                                                                                                      delegate:nil
//
//                                                                                                                                            cancelButtonTitle:@"确定"
//
//                                                                                                                                            otherButtonTitles:nil];
//
//                                              [alertView show];
//
//                                              break;
//
//                                          }
//
                                      case SSDKResponseStateFail:

                                      {

                    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"分享失败"          message:[NSString stringWithFormat:@"%@",error]            delegate:nil   cancelButtonTitle:@"OK"  otherButtonTitles:nil, nil];
                                              [alert show];
                                              break;
                                          }
                                      default:
                                          break;
                              }
                      }];
}

#pragma mark--右侧点击
-(void)rightTped:(UIButton *)sender{
    RedRecordListViewController *nextVC = [[RedRecordListViewController alloc] init];
    [self.navigationController pushViewController:nextVC animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
